package com.kehutong.payment.errcode;

import org.coraframework.mvc.http.result.JSONResult;

public class PayResult extends org.coraframework.mvc.http.result.Result {

    public static JSONResult error(PayErrorCode code) {
        if (code == PayErrorCode.OK) {
            return success();
        }

        return new JSONResult(code.code, code.message);
    }

    public static JSONResult error(PayErrorCode code, Object data) {
        if (code == PayErrorCode.OK) {
            return success(data);
        }

        return new JSONResult(code.code, code.message, "data", data);
    }
}
